<?php

declare (strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Model;

class InformationJobWanted extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected ?string $table = 'information_job_wanted';
    public static $sexList = [1 => '男', 2 => '女', 3 => '保密'];
    public static $qualificationList = [1 => '初中', 2 => '高中', 3 => '大专', 4 => '本科', 5 => '硕士研究生', 6 => '博士研究生', 7 => '其他'];
    public function information()
    {
        return $this->belongsTo(Information::class, 'information_id');
    }
    public function img()
    {
        return $this->belongsTo(Upload::class, 'img_id');
    }
    public function city()
    {
        return $this->belongsTo(City::class, 'city_id');
    }
    public function trade()
    {
        return $this->belongsTo(Trade::class, 'trade_id');
    }
    public function getSexTextAttribute()
    {
        return static::$sexList[$this->sex] ?? '保密';
    }
    public function getQualificationTextAttribute()
    {
        return static::$qualificationList[$this->qualification] ?? '保密';
    }
    public function info()
    {
        return ['name' => $this->username ?? '', 'sex' => $this->sex ?? 3, 'sex_text' => $this->sex_text, 'qualification' => $this->qualification ?? '', 'qualification_text' => $this->qualification_text ?? '', 'university' => $this->university ?? '', 'city_id' => $this->city_id ?? '', 'city' => $this->city->name ?? '', 'trade_id' => $this->trade_id ?? '', 'trade' => $this->trade->name ?? '', 'pay' => $this->pay ?? '面议', 'work_experience' => $this->work_experience ?? '', 'education' => $this->education ?? '', 'content' => $this->content ?? '', 'img_id' => $this->img_id ?? '', 'img' => stripslashes(($this->img->url ?? ''))];
    }
}